Skip to content

fix(openrouter): use model context length#3088

Merged
rekram1-node merged 2 commits into
anomalyco:devfrom
snvtac:snvtac/2796-openrouter-context-length
Jul 9, 2026
Merged

fix(openrouter): use model context length#3088
rekram1-node merged 2 commits into
anomalyco:devfrom
snvtac:snvtac/2796-openrouter-context-length

Conversation

@snvtac

@snvtac snvtac commented Jul 7, 2026

Copy link
Copy Markdown
Contributor

Summary

  • use OpenRouter model-level context_length for synced limit.context
  • keep top_provider.max_completion_tokens as the output limit source
  • update the current xiaomi/mimo-v2.5 OpenRouter TOML by removing the stale 32K context override
  • add regression coverage for shorter top_provider.context_length values

Fixes #2796.

Validation

  • bun test packages/core/test/sync.test.ts
  • bun run test from packages/sdk
  • bun validate
  • git diff --check
  • bun models:sync openrouter --dry-run / bun models:sync openrouter showed the target xiaomi/mimo-v2.5.toml data fix; unrelated live OpenRouter catalog drift was not included

Known existing failure

  • bun test still fails catalog generation > repository open-weight model metadata includes weights links because existing model metadata entries are missing weights links (for example nvidia/nemotron-3-super-120b-a12b and related entries).

@snvtac
snvtac force-pushed the snvtac/2796-openrouter-context-length branch from 108ad39 to c7990b3 Compare July 7, 2026 12:40
# Conflicts:
#	packages/core/test/sync.test.ts
@rekram1-node
rekram1-node merged commit 92f0103 into anomalyco:dev Jul 9, 2026
2 checks passed
@github-actions

github-actions Bot commented Jul 9, 2026

Copy link
Copy Markdown
Contributor

The change is well-targeted and internally consistent. The logic switch at openrouter.ts:181 from model.top_provider.context_length ?? model.context_length to model.context_length aligns OpenRouter with the other sync providers (cloudflare-workers-ai, ovhcloud, baseten, llmgateway all use model-level context), and the new regression test correctly captures the behavioral delta — it would fail under the old top_provider-first logic and passes under the new logic. Existing OpenRouter tests use equal context_length values or hit the isUnavailable skip path, so they remain valid. The xiaomi/mimo-v2.5.toml edit removes the stale 32K override so the provider entry inherits context = 1_048_576 from models/xiaomi/mimo-v2.5.toml, which matches what the new sync would emit. The top_provider.context_length schema field is now unused but retaining it is harmless.

  • [low] packages/core/src/sync/providers/openrouter.ts:181 - The PR reinterpretation rests on the OpenRouter API field semantics (context_length = model context window vs. top_provider.context_length = per-provider serving limit), but neither the PR body nor a file comment cites OpenRouter's API/model docs to confirm that distinction. The xiaomi/mimo-v2.5 data change is corroborated by the matching models/xiaomi/mimo-v2.5.toml metadata, so this is not blocking; a first-party OpenRouter API reference stating what each context_length field represents would strengthen the broader behavioral change.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

OpenRouter provider context length uses top_provider.context_length instead of model-level context_length

2 participants